package com.wyh.lotterysystem.dao.mapper;

import com.wyh.lotterysystem.dao.dataobject.ActivityDo;
import com.wyh.lotterysystem.service.enums.ActivityStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {
    @Insert("insert into activity (activity_name, description, status) " +
            "values (#{activityName},#{description},#{status})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void insertActivity(ActivityDo activityDo);

    @Select("select * from activity order by id desc limit #{offset}, #{pageSize}")
    List<ActivityDo> selectActivity(@Param("pageSize") Integer pageSize,
                                    @Param("offset") Integer offset);

    @Select("select count(1) from activity")
    int count();

    @Select("select * from activity where id = #{activityId}")
    ActivityDo selectActivityById(Integer activityId);

    @Update("update activity set status = #{status} where id = #{id}")
    void updateStatus(@Param("id") Integer id, @Param("status") String status);
}
